#region License Revision: 0 Last Revised: 6/18/2008 11:00 AM
/******************************************************************************
Copyright (c) Microsoft Corporation.  All rights reserved.


This file is licensed under the Microsoft Public License (Ms-PL). A copy of the Ms-PL should accompany this file. 
If it does not, you can obtain a copy from: 

http://www.microsoft.com/resources/sharedsource/licensingbasics/publiclicense.mspx
******************************************************************************/
#endregion // License
// VIEWS Sample
// Common Library for Silverlight Popup
// MS Research 2008
using System.Windows.Browser;
using ScriptInterop;

namespace SilverlightPopup
{
	/// <summary>
	/// data transfer object, pass data from main window to popup
	/// </summary>
	public class PopupData : JSObject
	{
		/// <summary>String holding JavaScript class name</summary>
		private static string thisClass = "SLPopupData";
		
		/// <summary>Get the JavaScript class name</summary>
		/// <returns type="String">The class name used in JavaScript </returns>		
		public override string ClassName
		{
			get { return thisClass; }
		}

		/// <summary>Construct a C# wrapper from a ScriptObject</summary>
		/// <param name="so">A ScriptObjet from JScript.</param>
		public PopupData(ScriptObject so) : base(so) { }

		/// <summary>Initializes a new instance of the PopupData object.</summary>
		/// <param name="x" type="Number">The pixel's x coordinate.</param>
		/// <param name="y" type="Number">The pixel's y coordinate.</param>
		/// <param name="xaml" type="string">The xaml.</param>
		public PopupData(int x, int y, string xaml)
		{	// Init to somewhere in Kirkland
			ScriptObject = CreateClass(x, y, xaml);
		}
		/// <summary type="Number">Gets or sets the pixel's x coordinate.</summary>
		public int X
		{
			get { return GetProperty<int>("x"); }
			set { SetProperty("x", value); }
		}
		/// <summary type="Number">Gets or sets the pixel's y coordinate.</summary>
		public int Y
		{
			get { return GetProperty<int>("y"); }
			set { SetProperty("y", value); }
		}
		/// <summary type="Number">Gets or sets the xaml property.</summary>
		public string Xaml
		{
			get { return GetProperty<string>("xaml"); }
			set { SetProperty("xaml", value); }
		}

		/// <summary>
		/// Get/Set the shown flag
		/// </summary>
		public bool Shown
		{
			get { return GetProperty<bool>("shown"); }
			set { SetProperty("shown", value); }
		}

		/// <summary>
		/// Show the popup with the appropriate data
		/// </summary>
		public void Show()
		{
			Invoke("Show");
		}

		/// <summary>
		/// Hide the popup
		/// </summary>
		public void Hide()
		{
			Invoke("Hide");
		}
	}
}
